<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var arr = [1,2,3,2,4,5,6,6,6,6,5,5,5,4,1,22,3]

        // for循环
        var  newarr = [];
        for (var i=0; i<arr.length;i++){
            if(newarr.indexOf(arr[i])===-1){
                newarr.push(arr[i]);
            }
        }
        console.log(newarr);



            // reduce循环方式
        // var  res = arr.reduce(function(pre,current){
        //     pre.indexOf(current)===-1?pre.push(current):null;
        //     return pre;
        // },[]);
        // console.log(res);
    </script>
</body>
</html>